function好難


Q1: 請問以下會輸出什麼內容?

let x = y(function z() {
 console.log('I am z') 
})
function y(fn) {
  fn()
  console.log('I am y')
  return fn
}
x()
console.log(y)  
console.log(x)  
console.log(x === y)
answer
I am z
I am y
I am z
[Function: y]
[Function: z]
false

參考文章覺得 JavaScript function 很有趣的我是不是很奇怪








你可能感興趣的文章

Laravel view component cache

Laravel view component cache

[第一週] 認識  Git  及常用指令整理

[第一週] 認識 Git 及常用指令整理

React 我不知道的事 & 下半年期許

React 我不知道的事 & 下半年期許






留言討論